<template>
	<web-view :src="webUrl" :webview-styles="webviewStyles"></web-view>
</template>

<script>
	export default {
		data() {
			return {
				webUrl: getApp().globalData.WebUrl + 'message.html#/',
				webviewStyles: {
					progress: {
						color: '#FF3333',
					},
				},
			}
		},
		onLoad(option) {},
		onShow() {
			let user_id = uni.getStorageSync('user_id')
			let access_token = uni.getStorageSync('access_token')
			let open_id = uni.getStorageSync('open_id')
			const pages = getCurrentPages()
			const currentPage = pages[pages.length - 1]
			const currentPath = currentPage.route
			//console.log('小程序当前页面路径:', currentPath)
			let data = {
				user_id,
				access_token,
				open_id,
				currentPath,
				time: new Date().getTime(),
			}

			let pathParams = ''
			if (
				typeof data === 'object' &&
				data !== null &&
				!Array.isArray(data) &&
				Object.keys(data).length > 0
			) {
				for (let key in data) {
					pathParams += key + '=' + data[key] + '&'
				}
				pathParams = pathParams.slice(0, pathParams.length - 1)
			}

			let urlPath = this.webUrl;
			if (this.webUrl.indexOf('?') !== -1) {
				urlPath = this.webUrl.split('?')[0]
			}
			this.webUrl = urlPath + '?' + pathParams
			//console.log('h5路径:', this.webUrl)
		},
	}
</script>
<style>
	/* 隐藏嵌入页面的默认导航栏 */
	body {
		margin-top: 0 !important;
		/* 根据实际情况调整 */
	}
</style>